#include<iostream>
#include<vector>
using namespace std;

bool isTrueNumber(int num)
{
    int count = 0;
    while(num >0)
    {
        if(num%2==1)
            count++;
        else 
            count = 0;
        if(count>1)
        {
            return false;
        }
        num = num/2;
    }
    return true;
}
int findIntegers(int n) {
    int count = 0;
    for(int i=0;i<=n;i++)
    {
        if(isTrueNumber(i))
            count++;
    }
    return count;
}
int main()
{
    int n;
    cin >> n;
    int number = findIntegers(n);
    cout << number;
    return 0;
}